<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('员工花名册列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-lg-4 search-collapse">
            <form id="formId">
                <div class="col-lg-10">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>部门：</label>
                                <input type="text" name="department"/>
                            </li>
                            </li>
                            <li>
                                <label>组别：</label>
                                <input type="text" name="uGroup"/>
                            </li>
                            <li>
                                <label>职务：</label>
                                <input type="text" name="uPost"/>
                            </li>
                            <!--<li>
                                是否试用期内：<select name="mobCategory" th:with="type=${@dict.getType('rnx_sys_mob_category')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                            </li>-->
                            <li>
                                在职状态：<select name="workState" th:with="type=${@dict.getType('rnx_sys_work_state')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>工号：</label>
                                <input type="text" name="jobNumber"/>
                            </li>
                            <li>
                                <label>姓名：</label>
                                <input type="text" name="fullName"/>
                            </li>
                            <li>
                                <label>手机：</label>
                                <input type="text" name="mobilePhone"/>
                            </li>
                            <li>
                                是否合同有效期：<select name="contractCategory" th:with="type=${@dict.getType('rnx_sys_contract_category')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:roster:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:roster:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:roster:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:roster:export">
                <i class="fa fa-download"></i> 全部导出
            </a>
            <a class="btn btn-info" onclick="exportCheckExcel()" shiro:hasPermission="system:roster:export">
                <i class="fa fa-download"></i> 导出勾选数据
            </a>
            <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:roster:import">
                <i class="fa fa-upload"></i> 导入
            </a>
            <a class="btn btn-info" onclick="generateQrCode()">
                <i class="fa fa-download"></i> 下载邀请码
            </a>
            <a class="btn btn-info" onclick="inviteUser()" shiro:hasPermission="system:roster:invite">
                <i class="fa fa-user-plus"></i> 邀请员工完善信息
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js" />
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:roster:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:roster:remove')}]];
    var prefix = ctx + "system/roster";

    //二维码生成
    function generateQrCode(){
        $.operate.get(prefix + "/invite/logo", (r) => {
           window.location.href = ctx + "common/download/resource?resource=" + r.data
        });
    }

    function exportCheckExcel(){
        let data = $.table.selectFirstColumns();
        if(data.length <= 0){
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.loading("正在导出数据，请稍后...");
        $.operate.postJson(table.options.exportCheckUrl, data, function(result) {
            if (result.code == web_status.SUCCESS) {
                window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
            } else if (result.code == web_status.WARNING) {
                $.modal.alertWarning(result.msg)
            } else {
                $.modal.alertError(result.msg);
            }
            $.modal.closeLoading();
        });
    }

    /**
     * 邀请员工
     */
    function inviteUser(){
        $.modal.open('邀请员工','roster/inviteUser',500,500);
    }

    $(function () {
        var options = {
            pageSize: 50,
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            //导出选中数据
            exportCheckUrl: prefix + "/exportCheck",
            //查看详情
            detailUrl: prefix + "/detail/{id}",
            //导入请求地址
            importUrl: prefix + "/import",
            //模板生成
            importTemplateUrl: prefix + "/importTemplate",
            modalName: "员工花名册",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'serialNumber',
                    title: '序号',
                    visible: false
                },
                {
                    field: 'department',
                    title: '部门',
                },
                {
                    field: 'ugroup',
                    title: '组别'
                },
                {
                    field: 'upost',
                    title: '职务'
                },
                {
                    field: 'fullName',
                    title: '姓名'
                },
                {
                    field: 'jobNumber',
                    title: '工号'
                },
                {
                    field: 'gender',
                    title: '性别',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel([[${@dict.getType('rnx_sys_gender')}]], value);
                    }
                },
                {
                    field: 'age',
                    title: '年龄'
                },
                {
                    field: 'idNumber',
                    title: '身份证号',
                    width: 15,
                    widthUnit: '%'
                },
                {
                    field: 'dateOfBirth',
                    title: '出生年月',
                    visible: false
                },
                {
                    field: 'marriage',
                    title: '婚姻',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel([[${@dict.getType('rnx_sys_marriage')}]], value);
                    },
                    visible: false
                },
                {
                    field: 'nation',
                    title: '民族',
                    visible: false
                },
                {
                    field: 'mobilePhone',
                    title: '手机'
                },
                {
                    field: 'entryDate',
                    title: '入职时间'
                },
                {
                    field: 'regularTime',
                    title: '转正时间',
                    visible: false
                },
                {
                    field: 'mob',
                    title: '已入职时间/月',
                    visible: false
                },
                {
                    field: 'mobCategory',
                    title: '是否试用期内',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel([[${@dict.getType('rnx_sys_mob_category')}]], value);
                    }
                },
                {
                    field: 'probationSalary',
                    title: '试用期薪资',
                    visible: false
                },
                {
                    field: 'regularSalary',
                    title: '转正薪资',
                    visible: false
                },
                {
                    field: 'contractStart',
                    title: '合同开始',
                    visible: false
                },
                {
                    field: 'endOfContract',
                    title: '合同结束',
                    visible: false
                },
                {
                    field: 'contractCategory',
                    title: '是否合同有效期',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel([[${@dict.getType('rnx_sys_contract_category')}]], value);
                    }
                },
                {
                    field: 'contractRenewalTime',
                    title: '续签合同时间',
                    visible: false
                },
                {
                    field: 'renewalExpirationTime',
                    title: '续约到期时间',
                    visible: false
                },
                {
                    field: 'education',
                    title: '学历',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel([[${@dict.getType('rnx_sys_education')}]], value);
                    },
                    visible: false
                },
                {
                    field: 'universityOneIsGraduatedFrom',
                    title: '毕业院校',
                    visible: false
                },
                {
                    field: 'major',
                    title: '专业',
                    visible: false
                },
                {
                    field: 'graduationTime',
                    title: '毕业时间',
                    visible: false
                },
                {
                    field: 'nativePlace',
                    title: '籍贯'
                },
                {
                    field: 'natureOfHouseholdRegistration',
                    title: '户口性质',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel([[${@dict.getType('rnx_sys_nature_of_household_registration')}]], value);
                    },
                    visible: false
                },
                {
                    field: 'registeredResidence',
                    title: '户口所在地',
                    visible: false
                },
                {
                    field: 'currentAddress',
                    title: '现住址',
                    visible: false
                },
                {
                    field: 'emergencyContactName',
                    title: '紧急联系人',
                    visible: false
                },
                {
                    field: 'relationshipWithMyself',
                    title: '与本人关系',
                    visible: false
                },
                {
                    field: 'emergencyContactNumber',
                    title: '紧急联系人电话',
                    visible: false
                },
                {
                    field: 'bank',
                    title: '银行',
                    visible: false
                },
                {
                    field: 'bankOfDeposit',
                    title: '开户行',
                    visible: false
                },
                {
                    field: 'bankCardNumber',
                    title: '银行卡号',
                    visible: false
                },
                {
                    field: 'remarks',
                    title: '备注',
                    visible: false
                },
                {
                    field: 'mailbox',
                    title: '邮箱'
                },
                {
                    field: 'workState',
                    title: '在职状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel([[${@dict.getType('rnx_sys_work_state')}]], value);
                    }
                },
                {
                    field: 'certificateValidity',
                    title: '证件有效期',
                    visible: false
                },
                {
                    field: 'firstWorkingTime',
                    title: '首次参加工作时间',
                    visible: false
                },
                {
                    field: 'politicalOutlook',
                    title: '政治面貌',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel([[${@dict.getType('rnx_sys_political_outlook')}]], value);
                    },
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-arrows-alt"></i>详情</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>